package com.flick.student.resource;

import com.flick.po.Student;
import com.flick.student.ctrl.StudentCtrl;
import org.springframework.hateoas.Resource;

import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;

/**
 * @author flick on 2017/5/4.
 * @version 1.0
 */
public class StudentResource extends Resource {
    private String name;

    public StudentResource(Student student) {
        super(student);
        this.name = student.getName();
        String studentId = student.getId();
        add(linkTo(methodOn(StudentCtrl.class).get(studentId)).withRel("items"));
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
